package com.spider.silence.main;

import com.spider.silence.downloader.QZoneDownLoader;
import com.spider.silence.pool.QZoneDownLoaderPool;
import com.spider.silence.utils.PropertiesUtil;
import com.spider.silence.worker.QZoneWorker;
import org.apache.log4j.PropertyConfigurator;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by qiuhao on 2017/5/12.
 */
public class QZoneMain {

    public static void main(String[] args) throws Exception{
        PropertyConfigurator.configure( PropertiesUtil.getLogPro());//初始化日志环境
        QZoneDownLoaderPool downLoaderpool= QZoneDownLoaderPool.getInstance();
        QZoneDownLoader  downLoader= downLoaderpool.fetchDownLoader();
        downLoader.generateTask();
        downLoaderpool.releaseDownLoader(downLoader);
        ExecutorService pool =  Executors.newFixedThreadPool(3000);
        for(int i = 0; i<Integer.valueOf(PropertiesUtil.getVal("QZone.WorkerCount")); i++){//初始化QQ空间的Worker并且添加到线程池中
            pool.execute(new QZoneWorker());
        }
    }
}
